In [1]:
%pylab inline
from colormap import Colormap
In [2]:
c = Colormap()
In [3]:
cmap = c.cmap('cool')
In [4]:
# let us see what it looks like
c.test_colormap(cmap)
In [5]:
#Would be nice to plot a bunch of colormap to pick up one interesting
c.plot_colormap('diverging')
In [6]:
c.plot_colormap(c.misc)
In [7]:
c.plot_colormap(c.qualitative)
In [8]:
c.plot_colormap(c.sequentials)
In [9]:
c.plot_colormap(c.sequentials2)
In [10]:
# This list is implemented in colormap package itself
c.plot_colormap(c.diverging_black)
In [11]:
mycmap = c.cmap_linear('red', 'white', 'green(w3c)')
c.test_colormap(mycmap)
In [12]:
mycmap = c.cmap_bicolor('red', 'green(w3c)')
c.test_colormap(mycmap)
In [13]:
# there is also 2 extra maps from R
mycmap = c.get_cmap_heat()
c.test_colormap(mycmap)
In [18]:
# color can be given a a name available in
import colormap.xfree86 as colors
In [20]:
list(colors.XFree86_colors.keys())[0:5]
Out[20]:
In [22]:
#or
list(colors.XFree86_colors.values())[0:5]
Out[22]:
In [23]:
# or as RGB, HLS, HSV, YUX, Hexa format
from colormap import Color
In [24]:
co = Color('white')
In [25]:
co.hex
Out[25]:
In [26]:
mycmap = c.cmap_linear('red', '#FFFFFF', 'green(w3c)')
c.test_colormap(mycmap)
In [27]:
# Conversion between colors
c = Color('red')
c.rgb
Out[27]:
In [28]:
c.hls
Out[28]:
In [29]:
c.hex
Out[29]:
In [30]:
print(c)
Instead of using the Colormap class, you can also use the cmap_builder alias function andthe test_cmap function
In [31]:
from colormap import cmap_builder, test_cmap
In [26]:
mycm = cmap_builder('red', 'white', 'green')
test_cmap(mycm)
In [ ]: